var app = getApp();
var SERVER_URL=app.globalData.SERVER_URL;
Page({
    data: {
        active:['','','','active'],
        applyList:[]
    },
    onLoad(){
        this.getType();
        this.setData({

        });
    },
    onShow:function(){
        this.setData({

        });
    },
    check_click:function(e){
        let index=e.currentTarget.dataset.index;
        console.log(this.data);
        index=parseInt(index);
        var data=[];
        for(let i=0;i<=3;i++){
            data[i]='';
        }
        data[index]='active';
        this.setData({
            active:data
        });
        switch (index){
            case 0:
            case 1:
            case 2:
                this.getType(index);
                break;
            case 3:
                this.getType();
        }
    },

    getType:function(status){
        let url = "/apply/index";
        let openId = wx.getStorageSync('openId');
        if(status!=0){
            status = status || "";
        }
        url = SERVER_URL+url;
        var _self=this;
        _self.setData({
            applyList:[],
        });
        wx.showToast({
            title: '加载中',
            icon: 'loading',
            duration: 1000//loading时间
        });
        wx.request({
            url: url,
            data: {
                "key": app.globalData.key,
                openId: openId,
                status: status,
            },
            method: 'GET',
            header: {
                "Content-Type": "application/x-www-form-urlencoded"
            },
            success:function(res){
                let result = res.data;
                if(result && result.code==0){
                    _self.setData({
                        applyList:result.data,
                    });
                }
                else{
                    if(result && result.code==1){
                        _self.setData({
                            applyList:[],
                        });
                    }
                }
            }
        });
    },
});